<%-- 
    Document   : product_summary
    Created on : Mar 14, 2014, 8:24:35 PM
    Author     : ahmed
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<div class="item">
    <% pojo.Mobile mobile = (pojo.Mobile) session.getAttribute("mobile");%>
    <a href="view_product?id=<%= mobile.getId()%>">
        <img src="/E-comm/img/<%= mobile.getId()%>.jpg" id="img" width="202" height="173" /><br />
    </a>
    <br>
    <span><%= mobile.getPrice()%></span><a href="view_product?id=<%= mobile.getId()%>" class="view"><%= mobile.getName()%></a>
    <%
//        int userId = Integer.parseInt(request.getParameter("userId"));
        int mobileId = mobile.getId();
    %>
    <div class="buy"><div class="link"><%= mobileId %></div>Add to Cart</div>
    <script type="text/javascript">
        $(".buy").click(function() {
            $.get("AddToCart", {mobileId: $(this).find(".link").html()}, function(response){
                if (response == '1') alert('Product is out of stock.');
                else if (response == '2') alert("You don't have enough credit");
                else if (response != '0') $("body").html(response);
            });
        });
    </script>
</div>